function randomArray(arr) {
  let len = arr.length;
  for (let i = 0; i < len; i++) {
    // let random = parseInt(Math.random() * len);
    let random = Math.floor(Math.random() * len); // floor是向下取整
    let temp = arr[i];
    arr[i] = arr[random];
    arr[random] = temp;
  }
  return arr;
}

let arr = [1, 2, 3, 4, 5, 6];

console.log(randomArray(arr));
